<!-- 下属单位评价页面 -->
<template>
  <div class="appraise-container">
    <!--头部标题-->
    <el-form class="form-header" ref="form" :model="form" label-width="100px">
      <el-form-item label="项目名称" prop="extractItem">
        <el-input
          class="commonWidth"
          size="small"
          placeholder="请输入项目名称"
          v-model="queryParams.extractItem"
          @keyup.enter.native="handleQuery"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="抽取人单位" prop="createBy">
        <el-select
          v-model="form.createBy"
          placeholder="请选择抽取人单位"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChangepenson"
        >
          <el-option
            v-for="type in unitTypeponsonOptions"
            :key="type.userId"
            :label="type.nickName"
            :value="type.userId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="抽取库" prop="randomUnittypeId">
        <el-select
          class="commonWidth"
          v-model="form.randomUnittypeId"
          placeholder="请选择抽取库"
        >
          <el-option
            v-for="item in form.extractData"
            :key="item.unittypeId"
            :label="item.unittypeName"
            :value="item.unittypeId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="btns">
        <el-button
          class="search-btn"
          icon="el-icon-search"
          type="primary"
          size="mini"
          @click="onSearch"
          >搜索</el-button
        >
        <el-button class="el-icon-refresh" size="mini" @click="reset"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <!--表格内容-->
    <el-table
      :data="articleList"
      @current-change="currentRowChange"
      style="width: 100%"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="extractItem" align="left" label="项目名称" />
      <el-table-column prop="extractUser" align="left" label="经办人" />
      <!-- <el-table-column prop="extractAddress" align="left" label="抽取地点" /> -->
      <el-table-column prop="tenderStartTime" align="left" label="抽取时间" />
      <!-- <el-table-column label="建设地址" align="left" prop="extractAddress" /> -->
      <el-table-column
        label="抽取人单位"
        align="left"
        prop="createBy"
        width="250"
      />
      <el-table-column
        prop="extractPrice"
        align="left"
        label="工程费用（万元）"
      >
        <template slot-scope="scope">
          <div>{{ scope.row.extractPrice }}</div>
        </template>
      </el-table-column>
      <el-table-column
        label="中介机构服务费（万元）"
        align="left"
        prop="maxPrice"
      />
      <el-table-column
        prop="unitTypeName"
        label="抽取库"
        width="200"
      ></el-table-column>
      <el-table-column
        prop="extractApproveStatus"
        align="center"
        label="审批状态"
      >
        <template slot-scope="scope">
          <div>{{ scope.row.extractApproveStatus | formatStatus }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="address" align="center" label="操作" width="168">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="loadExtractArticle(scope.row)"
            :disabled="scope.row.extractApproveStatus == 8"
            icon="el-icon-s-comment"
            >项目评价</el-button
          >
          <el-button
            size="mini"
            type="text"
            @click="printMarkSheet(scope.row)"
            icon="el-icon-printer"
            >打印评分表</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <div class="pagination">
      <el-pagination
        :current-page.sync="currentPage"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        :disabled="isPaginationDisabled"
        @current-change="currentChange"
        @size-change="handleSizeChange"
      />
    </div>
    <!--dialog项目评价弹窗-->
    <el-dialog
      title="项目评价"
      :visible.sync="commentDialogVisible"
      width="60%"
      @close="closeCommentDialog"
      :close-on-click-modal="false"
    >
      <div class="radio-wrap">
        <label class="label">是否正常结束:</label>
        <el-radio-group v-model="isNormal">
          <el-radio :label="0">是</el-radio>
          <el-radio :label="1">否</el-radio>
        </el-radio-group>
      </div>
      <quotationConfirm
        class="tableComponent"
        :quotationConfirm="quotationConfirm"
        style="margin-left: -48px"
      />
      <!-- <quotationConfirm class="tableComponent" :quotationConfirm="price" /> -->
      <!-- <simpleTable :simpleTableData="simpleTableData"></simpleTable> -->
      <!--评分扣分具体事项-->
      <div class="score-wrap">
        <div class="time-wrap">
          <div class="begin-time">
            <label><i class="must">*</i>项目开始时间</label>
            <el-date-picker
              class="remain"
              v-model="saveData.projectStartTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择时间（YYYY-MM-DD）"
              :disabled="isNormal == 1"
            />
          </div>
          <div class="end-time">
            <label><i class="must">*</i>项目结束时间</label>
            <el-date-picker
              class="remain"
              v-model="saveData.projectEndTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择时间（YYYY-MM-DD）"
              :disabled="isNormal == 1"
            />
          </div>
        </div>
        <div>
          <el-row class="cash-end">
            <el-col>
              <label
                ><i
                  class="must"
                  style="position: absolute;
                    top: 50%;
                    left: -10px;
                    transform: translateY(-50%);"
                  >*</i
                >结算金额（万元）</label
              >
              <el-input
                v-model="currentRow.settleAmount"
                type="number"
                class="calc-cash"
                :disabled="isNormal == 1"
              />
            </el-col>
          </el-row>
<!--          <el-row>-->
<!--            <el-col :span="12" style="margin-left: 23px; margin-top: 10px">-->
<!--              <label>-->
<!--                服务评分-->
<!--              </label>-->
<!--              <el-input-->
<!--                v-model="currentRow.serviceScore"-->
<!--                type="number"-->
<!--                :min="0"-->
<!--                :max="100"-->
<!--                controls-position="right"-->
<!--                style="width: 220px"-->
<!--                :disabled="isNormal == 1"-->
<!--              />-->
<!--            </el-col>-->
<!--          </el-row>-->
        </div>
        <!--违规扣分-->
        <div class="current-score">
          <span
            >当前扣分值：{{ currentDeductScore() }}分</span
          >
        </div>
        <div class="deduction-wrap">
          <label><i class="must">*</i>违规扣分</label>
          <ul class="remain">
            <li v-for="(item, index) in saveData.radioList" :key="index">
              <div class="deduction-title">{{ item.ruleName }}</div>
              <el-radio
                v-model="item.whetherDeduct"
                label="0"
                :disabled="isNormal == 1"
                >是</el-radio
              >
              <el-radio
                v-model="item.whetherDeduct"
                label="1"
                :disabled="isNormal == 1"
                >否</el-radio
              >
            </li>
          </ul>
        </div>
        <div class="select-file">
          <label><i class="must">*</i>评分表</label>
          <el-upload
            class="remain"
            ref="uploadFile"
            :accept="acceptType"
            :limit="1"
            :on-exceed="onExceed"
            action=""
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :http-request="uploadFile"
            :file-list="fileList"
            :disabled="isNormal == 1"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">
              请上传bmp，gif，jpg，jpeg，png，doc，docx，xls，xlsx，ppt，pptx，html，htm，txt，rar，zip，gz，bz2，pdf文件，且不超过10MB
            </div>
            <div class="uploadimg-wrap">
              <el-image
                class="uploadimg"
                v-for="(item, index) in imgUrl"
                :key="index"
                style="width: 100px; height: 100px"
                :src="item"
                fit="cover"
              />
            </div>
          </el-upload>
        </div>
        <div class="deduction-reason-wrap">
          <label>{{isNormal == 0 ? "备注" : "原因"}}</label>
          <textarea
            class="remain"
            v-model="saveData.deductReason"
            cols="30"
            rows="10"
          ></textarea>
        </div>
      </div>
      <!--底部按钮-->
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveInfo">保存</el-button>
        <el-button @click="commentDialogVisible = false">取消</el-button>
      </span>
    </el-dialog>
    <!--dialog单位详情弹窗-->
    <!-- <el-dialog title="单位详情" :visible.sync="detailDialogVisible" width="60%">
      <quotationConfirm :quotationConfirm="unitInfo"></quotationConfirm>
    </el-dialog> -->
    <DetailDialog :visible.sync="detailDialogVisible" :formUnit="unitInfo" />
    <!-- 打印 -->
    <el-dialog :visible.sync="openPrint" width="800px" append-to-body>
      <el-form
        ref="form"
        label-width="120px"
        style="width: 700px; padding-left: 50px"
      >
        <table
          class="printTable"
          border="1"
          cellspacing="0"
          cellpadding="0"
          id="printMe"
          width="100%"
          height="800px"
          @formatter="unitTypeFormat"
        >
          <caption align="top" class="title">
            重庆高新开发建设投资集团有限公司中介机构服务评价表
          </caption>
          <tr>
            <td colspan="3" height="40px" class="topfont topfont-name noBorder">
              申请单位：{{ printRow.createDept }}
            </td>
          </tr>
          <tr>
            <td rowspan="3" width="100px" class="bigfont">
              项 目 基<br />本 情 况
            </td>
            <td width="150px" height="60px" class="small project-name">
              项 目 名 称
            </td>
            <th colspan="3" class="input project-name-1 rightBorder">
              {{ printRow.extractItem }}
            </th>
          </tr>
          <tr>
            <td height="60px" class="small project-name">建 设 地 址</td>
            <th colspan="3" class="input font-family rightBorder">
              {{ printRow.extractAddress }}
            </th>
          </tr>
          <tr>
            <td width="80px" height="60px" class="small project-name">
              工 程 费 用<br />(万 元)
            </td>
            <th width="130px" class="input font-family">
              {{ printRow.extractPrice }}
            </th>
            <td width="130px" class="small project-name">建 设 周 期</td>
            <th class="input font-family rightBorder">
              {{ printRow.extractPeriod }}
            </th>
          </tr>
          <tr>
            <td rowspan="6" class="bigfont">
              中介<br />单位<br />服务<br />评价
            </td>
            <td height="60px" class="small project-name">业务类型</td>
            <th class="input font-family rightBorder" colspan="3">
              {{ printRow.extractBusinessType }}
            </th>
          </tr>
          <tr>
            <td height="60px" class="small project-name">服务单位</td>
            <th class="input font-family rightBorder" colspan="3">
              {{ printRow.randomUnitName }}
            </th>
          </tr>
          <tr>
            <td
              height="60px"
              colspan="4"
              class="zhong project-name rightBorder"
            >
              项目起始时间：{{ printRow.projectStartTime }}
            </td>
          </tr>
          <tr>
            <td
              colspan="4"
              class="fontitem12 project-name rightBorder"
              height="40px"
              style="font-size: 12px"
            >
              从“是否按照时间完成工程项目”、“工作质量是否合格”、“施工过程中交流是否顺畅、友好”等方面进行评价
            </td>
          </tr>
          <tr>
            <td height="60px" class="small project-name">扣分</td>
            <th class="input font-family rightBorder" colspan="3">
              {{ printRow.deduct }}
            </th>
          </tr>
          <tr>
            <td height="60px" class="small project-name">扣分理由</td>
            <th class="input font-family rightBorder" colspan="3">
              {{ printRow.deductCause }}
            </th>
          </tr>
          <tr>
            <td rowspan="3" class="bigfont bottomBorder">参与抽<br />取人员</td>
            <td height="80px" class="small project-name">经办人<br />意见：</td>
            <th class="input font-family rightBorder" colspan="3"></th>
          </tr>
          <tr>
            <td height="60px" class="small project-name">
              部门负责人<br />意见：
            </td>
            <th class="input font-family rightBorder" colspan="3"></th>
          </tr>
          <tr>
            <td height="60px" class="small project-name bottomBorder">
              公司负责人<br />意见：
            </td>
            <th
              class="input font-family rightBorder bottomBorder"
              colspan="3"
            ></th>
          </tr>
        </table>
        <el-button
          v-print="'#printMe'"
          type="primary"
          style="margin-top: 10px; margin-left: 90%"
          >打 印</el-button
        >
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import quotationConfirm from "@/common/operation/quotationConfirm";
import simpleTable from "@/common/operation/simpleTable";
import { getUnit } from "@/api/unit/unit.js";
import { listUser } from "@/api/system/user";
import {
  getExtractOption,
  getExtractList,
  getExtractArticle,
  getScore,
  saveDeduction,
  Department,
  printMark,
} from "@/api/unit/extract.js";
import { listUnittype } from "@/api/unit/unittype";
import { evaluate } from "@/api/unit/extract";
import service from "../../components/utils/request.js";
import DetailDialog from "@/common/detailDialog";

export default {
  name: "appraise",
  components: {
    quotationConfirm,
    simpleTable,
    DetailDialog,
  },
  data() {
    return {
      // 单位类型字典
      unitTypeOptions: [],
      extractId: null,
      commentDialogVisible: false, // 是否打开项目评价弹窗
      detailDialogVisible: false, // 是否打开查看详情弹窗
      isPaginationDisabled: false, // 是否禁用分页
      currentPage: 1,
      //抽取人单位字典
      unitTypeponsonOptions: [],
      // 传给quotationConfirm的数据
      quotationConfirm: [],
      price: [],
      // 点击表格展示的公司信息
      currentObj: [],
      simpleTableData: {
        title: ["单位名称", "状态", "报价金额（元）", "抽取时间", "操作"], //使用方传， 组件第一个li里面的div的循环数据
        list: [],
      },
      form: {
        extractItem: "",
        extractUser: "",
        randomUnittypeId: "",
        extractData: [], //抽取库数据，
        userId: "",
        extractId: "",
        extractSignUrl: "",
      },

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        extractItem: null,
        extractUser: null,
        extractAddress: null,
        extractPrice: null,
        extractApproveStatus: null,
        maxPrice: null,
        randomUnittypeId: null,
        userId: null,
      },
      articleList: [], //表格列表
      pageSize: 10, //分页大小
      totalSize: 0, // 数据总条数
      pageSizes: [10, 20, 30, 50],
      pageNum: 1, // 数据页码
      // 上传文件列表地址
      fileList: [],
      // 接受的文件类型
      acceptType:
        "bmp,gif,jpg,jpeg,png,doc,docx,xls,xlsx,ppt,pptx,html,htm,txt,rar,zip,gz,bz2,pdf",
      // 图片类型
      imageType: "bmp,gif,jpg,jpeg,png",
      // 上传文件的图片地址
      imgUrl: [],
      // 传值给quotationComfirm组件展示
      unitInfo: [],
      //  提交给后台的数据
      saveData: {
        fileUrl: [],
        endDate: "", // 选择日期
        deductReason: "", // 扣分原因
        radioList: [],
      },
      // 当前行数据
      currentRow: {},
      companyInfo: [],
      openPrint: false,
      printRow: {},
      isNormal: 0,
    };
  },
  created() {
    listUnittype(this.unitTypeParams).then((response) => {
      this.unitTypeOptions = response.rows;
    });
    this.loadExtractOption();
    this.loadExtractList();
    listUser().then((response) => {
      this.unitTypeponsonOptions = response.rows;
    });
  },
  methods: {
    //抽取人单位
    UnitTypeChangepenson(value) {
      listUser().then((response) => {
        for (var o = 0; o < response.rows.length; o++) {
          if (value == response.rows[o].userId) {
            this.queryParams.createBy = response.rows[o].nickName;
          }
        }
      });
    },
    // 单位库类型翻译
    unitTypeFormat(row, column) {
      return this.selecttypeLabel(this.unitTypeOptions, row.randomUnittypeId);
    },
    // 点击搜索按钮
    onSearch() {
      this.loadExtractList();
    },
    // 改变页码显示不同的数据
    currentChange(page) {
      this.queryParams.pageNum = page;
      this.loadExtractList();
    },
    // 点击重置
    reset() {
      this.queryParams.extractItem = null;
      this.form.extractUser = null;
      this.form.randomUnittypeId = null;
      if (this.form.createBy != null) {
        this.form.createBy = null;
      }
      this.queryParams.createBy = null;
      this.loadExtractList();
      this.form.extractId = "";
      this.form.extractApproveStatus = "";
      this.form.ProjectAmount = "";
    },
    // 每页显示的数据条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.currentPage = 1;
      this.queryParams.pageNum = 1;
      this.loadExtractList();
    },
    // 去到项目评价弹窗
    goDialog() {},
    // 获取抽取库数据
    async loadExtractOption() {
      const res = await getExtractOption();
      try {
        if (res.code === 200) {
          this.form.extractData = res.rows.map((item) => {
            return item;
          });
        } else {
          this.$message.error(res.msg);
        }
      } catch (e) {
        this.$message.error(e);
      }
    },
    //获取表格列表数据
    async loadExtractList() {
      await Department().then((response) => {
        this.form.userId = response.data.userId;
      });
      //this.tableLoading = true;
      this.isPaginationDisabled = true;
      try {
        this.queryParams.extractApproveStatus = "7";
        this.queryParams.userId = this.form.userId;
        this.queryParams.randomUnittypeId = this.form.randomUnittypeId;
        const res = await getExtractList(this.queryParams);
        if (res.code === 200) {
          const result = res.rows;
          for (var i = 0; i < result.length; i++) {
            let obj = result[i];
            for (const j in obj) {
              if (obj[j] === null) {
                // console.log(3333,obj[j])
                obj[j] = "";
              } else {
                // console.log(2222,obj[j])
                obj[j] = obj[j];
              }
            }
          }
          this.articleList = result;
          this.totalSize = res.total;
        }
      } catch (e) {
        this.$message.error(e);
      } finally {
        this.tableLoading = false;
        this.isPaginationDisabled = false;
      }
    },
    // 删除文件之前
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    // 删除文件
    handleRemove(file, fileList) {
      const index = this.fileList.find((item) => item.uid === file.uid);
      const i = this.fileList.find((item) => item === file.url);
      this.fileList.splice(index, 1);
      this.imgUrl.splice(i, 1);
      this.saveData.fileUrl = this.fileList.map((item) => item.url);
    },
    // 超过上传个数
    onExceed() {
      this.$message.error("最多只能上传一个文件");
    },
    // 上传文件，获取文件地址
    async uploadFile(eleFile) {
      // console.log(eleFile);
      const file = eleFile.file;
      let fileType = file.name.split(".");
      fileType = fileType[fileType.length - 1];
      if (file.size > 10 * 1024 * 1024) {
        this.$message.error("文件大小不能超过10MB");
        return;
      }
      if (!this.acceptType.includes(fileType)) {
        this.$message.error("文件类型不正确");
        let uid = file.uid;
        let idx = this.$refs.uploadFile.uploadFiles.findIndex(
          (item) => item.id === uid
        );
        this.$refs.uploadFiles.splice(idx, 1);
        return;
      }
      const fd = new FormData();
      fd.append("file", file);
      try {
        const res = await service.post("/common/upload", fd, {
          headers: { "content-type": "multipart/form-data" },
        });
        if (res.code === 200) {
          this.fileList.push({
            name: file.name,
            url: res.url,
          });
          if (this.imageType.includes(fileType)) {
            this.imgUrl.push(res.url);
          }
          this.saveData.fileUrl = this.fileList.map((item) => item.url);
          this.$message({
            message: "上传成功",
            type: "success",
          });
        }
      } catch (e) {
        this.$message.error(e);
      }
    },
    // 当表格的当前行发生变化的时候会触发该事件
    currentRowChange(currentRow) {
      this.currentRow = currentRow;
      if (!currentRow) this.currentRow = {};
      (this.quotationConfirm = [
        // {
        //   name: "申请单位",
        //   detailInfo: currentRow.createBy,
        //   showTwo: true,
        // },
        {
          name: "项目名称",
          detailInfo: currentRow?.extractItem,
          showTwo: true,
        },
        {
          name: "抽取时间",
          detailInfo: currentRow?.tenderStartTime,
          showTwo: true,
        },
        {
          name: "中介服务单位",
          detailInfo: this.companyInfo[0]?.randomUnitName,
          showTwo: false,
        },
        // {
        //   name: "建设地址",
        //   detailInfo: currentRow.extractAddress,
        //   showTwo: true,
        // },
        // {
        //   name: "建设周期",
        //   detailInfo: currentRow.extractPeriod,
        //   showTwo: true,
        // },
        // {
        //   name: "工程费用（万元）",
        //   detailInfo: currentRow.extractPrice,
        //   showTwo: true,
        // },
        // {
        //   name: "工程概况",
        //   detailInfo: currentRow.projectOverview,
        //   showTwo: true,
        // },
      ]),
        (this.price = [
          {
            name: "中介机构服务费（万元）",
            detailInfo: currentRow?.maxPrice,
            showTwo: true,
          },
          {
            name: "抽取要求",
            detailInfo: currentRow?.extractBanReason, //不确定
            showTwo: true,
          },
          {
            name: "经办人",
            detailInfo: currentRow?.extractCharge,
            showTwo: true,
          },
          {
            name: "联系电话",
            detailInfo: currentRow?.extractPhone,
            showTwo: true,
          },
          {
            name: "抽  取  人",
            detailInfo: currentRow?.extractUser,
            showTwo: true,
          },
          {
            name: "抽取地点",
            detailInfo: currentRow?.extractPlace,
            showTwo: true,
          },
          {
            name: "抽取时间",
            detailInfo: currentRow?.tenderStartTime,
            showTwo: false,
          },
          {
            name: "抽  取  库",
            detailInfo: currentRow?.unitTypeName,
            showTwo: true,
          },
          {
            name: "业务类型",
            detailInfo: currentRow?.extractBusinessType,
            showTwo: true,
          },
          {
            name: "签字表",
            detailInfo: currentRow?.extractSignUrl,
            showimg: true,
            showTwo: true,
          },
          {
            name: "是否需要驻场服务",
            detailInfo: currentRow?.extractResident == 0 ? "是" : "否",
            showTwo: false,
          },
          {
            name: "驻场服务人数(至少)",
            detailInfo:
              currentRow?.extractResident == 0
                ? currentRow.extractResidentNumber
                : "",
            showTwo: true,
          },
          {
            name: "完成时限",
            detailInfo:
              currentRow?.extractResident == 0
                ? currentRow.extractLimitedTime
                : "",
            showTwo: true,
          },
          {
            name: "驻 场 要 求",
            detailInfo:
              currentRow?.extractResident == 0
                ? currentRow.extractStationRequire
                : "",
            showTwo: false,
          },
          {
            name: "抽取单位数",
            detailInfo: currentRow?.extractNumber,
            showTwo: false,
          },
        ]);
    },
    // 获取单位名称等数据
    async loadExtractArticle(row) {
      this.currentRow = row;
      row.markSheet ? this.imgUrl.push(row.markSheet) : null;
      this.commentDialogVisible = true;
      //  调接口，将项目id currentRow.extractId传给后台，获取当前行的评分数据
      getScore().then((res) => {
        this.saveData.radioList = res.rows;
        this.saveData.radioList.forEach((item) => {
          if (item.whetherDeduct === null) {
            item.whetherDeduct = "0";
          }
        });
      });
      const extractId = row.extractId || this.ids;
      const res = await getExtractArticle({ randomBan: 3, extractId });
      const companyInfo = res.rows;
      for (var i = 0; i < companyInfo.length; i++) {
        const obj = companyInfo[i];
        for (const j in obj) {
          if (obj[j] === null) {
            obj[j] = "";
          } else {
            obj[j] = obj[j];
          }
        }
      }
      this.companyInfo = companyInfo;
      this.quotationConfirm[2].detailInfo = companyInfo[0].randomUnitName;
      companyInfo.forEach((item) => {
        this.simpleTableData.list.push([
          item.randomUnitName,
          this.handleRandomBan(item.randomBan),
          item.bidamount === null ? "" : item.bidamount,
          item.createTime,
          {
            handleTile: "查看详情",
            org: item,
            callBack: (currentRow, index) => {
              // console.log("currentRow",currentRow,"index",index)
              this.currentObj = currentRow[currentRow.length - 1].org;
              this.detailDialogVisible = true;
              // 获取单位详细信息
              getUnit(this.currentObj.randomUnitId).then((res) => {
                const relativeInfo = res.data;
                for (const j in relativeInfo) {
                  if (relativeInfo[j] === null) {
                    relativeInfo[j] = "";
                  } else {
                    relativeInfo[j] = relativeInfo[j];
                  }
                }
                // 传给组件展示的公司信息
                // this.unitInfo = [
                //   {
                //     name: "单位名称",
                //     detailInfo: relativeInfo.unitName,
                //     showTwo: true,
                //   },
                //   {
                //     name: "组织机构代码",
                //     detailInfo: relativeInfo.unitInstitutionId,
                //     showTwo: true,
                //   },
                //   {
                //     name: "法定代表人",
                //     detailInfo: relativeInfo.unitRepresentative,
                //     showTwo: true,
                //   },
                //   {
                //     name: "法定代表人联系电话",
                //     detailInfo: relativeInfo.unitRepresentativePhone,
                //     showTwo: true,
                //   },
                //   {
                //     name: "联系人",
                //     detailInfo: relativeInfo.unitLinkman,
                //     showTwo: true,
                //   },
                //   {
                //     name: "联系电话",
                //     detailInfo: relativeInfo.unitPhone,
                //     showTwo: true,
                //   },
                //   {
                //     name: "单位序号",
                //     detailInfo: relativeInfo.unitSort,
                //     showTwo: true,
                //   },
                //   {
                //     name: "资质等级",
                //     detailInfo: relativeInfo.unitNaturalGrade,
                //     showTwo: true,
                //   },
                //   {
                //     name: "资质范围",
                //     detailInfo: relativeInfo.unitNaturalScope,
                //     showTwo: true,
                //   },
                //   {
                //     name: "注册地址",
                //     detailInfo: relativeInfo.unitAddress,
                //   },
                //   {
                //     name: "备注",
                //     detailInfo: relativeInfo.unitRemarks,
                //   },
                // ];
                this.unitInfo = relativeInfo;
              });
            },
          },
        ]);
        for (var i = 0; i < this.simpleTableData.list.length; i++) {
          if (i >= 1) {
            this.simpleTableData.list.splice(0, 1);
          }
        }
      });
    },

    // 关闭项目评价弹窗
    closeCommentDialog() {
      this.fileList = [];
      this.saveData.fileUrl = [];
      this.imgUrl = [];
      this.saveData.deductReason = "";
      (this.saveData.endDate = ""), this.loadExtractList();
    },
    //单位选择select改变方法
    UnitTypeChange(value) {
      //让table显现出来
      //查询table数据
      this.UnitqueryParams.unitType = value;
      this.UnitqueryParams.extractId = this.form.extractId;
      //console.log('extractId' + this.UnitqueryParams.extractId);
      randomlist(this.UnitqueryParams).then((response) => {
        this.unitList = response.rows;
        this.loading = false;
      });
    },
    // 处理公司状态
    handleRandomBan(val) {
      switch (val) {
        case "0":
          return "正常";
        case "1":
          return "排除";
        case "2":
          return "中签";
        case "3":
          return "中标";
        case "4":
          return "未中标";
        case "5":
          return "废除报价";
      }
    },
    // 点击项目评价弹窗保存按钮
    async saveInfo() {
      // console.log(844,this.saveData.fileUrl)
      // this.saveData.fileUrl = this.saveData.fileUrl.join(",");
      let extract = {};
      if (this.isNormal == 0) {
        if (this.currentRow.settleAmount <= 0) {
          this.$message.error("结算金额需大于0");
          return;
        }
        const scoreindexList = this.saveData.radioList;
        const deductFlag = scoreindexList.some(
          (item) => item.whetherDeduct == 1
        );
        if (deductFlag && this.imgUrl.length == 0) {
          this.$message.error("包含违规扣分，请上传评分表");
          return;
        }
        if (
          this.currentDeductScore() > 0 &&
          this.saveData.deductReason.length < 1
        ) {
          this.$message.error("包含违规扣分，请填写备注");
          return;
        }
        scoreindexList.forEach((item) => {
          item.extractId = this.currentRow.extractId;
          item.extractItem = this.currentRow.extractItem;
          item.remark = this.saveData.deductReason;
        });
        if (!this.saveData.projectStartTime) {
          this.$message.error("请选择开始日期");
          return;
        }
        if (!this.saveData.projectEndTime) {
          this.$message.error("请选择结束日期");
        }
        extract = {
          extractId: this.currentRow.extractId,
          extractItem: this.currentRow.extractItem,
          projectStartTime: this.saveData.projectStartTime,
          projectEndTime: this.saveData.projectEndTime,
          scoreindexList,
          markSheet: this.imgUrl.toString(),
          settleAmount: this.currentRow.settleAmount,
          isNormal: this.isNormal,
          serviceScore: this.currentRow.serviceScore,
          deductReason: this.saveData.deductReason
        };
      } else {
        if(this.saveData.deductReason.length < 1) {
          this.$message.error("请输入非正常结束原因");
          return;
        }
        extract = {
          extractId: this.currentRow.extractId,
          isNormal: this.isNormal,
          abnormalReason: this.saveData.deductReason
        };
      }
        evaluate(extract)
          .then((res) => {
            this.$message.success(res.msg);
            this.commentDialogVisible = false;
            this.loadExtractList();
          })
          .catch((e) => {
            this.$message.error(e);
          });

      // 违规扣分
      // try {
      //   const query = JSON.stringify(obj);
      //   this.$message.success(res.msg);
      //   this.commentDialogVisible = false;
      // } catch (e) {
      //   this.$message.error(e);
      // }
    },
    // 当前扣分值
    currentDeductScore() {
      let deduct = 0;
      this.saveData.radioList.forEach((item) => {
        if (item.whetherDeduct === "1") {
          deduct += 2;
        }
      });
      return deduct;
    },
    // 打印评分表
    async printMarkSheet(row) {
      this.openPrint = true;
      row.extractApproveStatuss = [];
      row.extractIdList = [];
      row.scoringRubric = null;
      for (let i in row) {
        if (row[i] === "") {
          delete row[i];
        }
      }
      const res = await printMark(row);
      this.printRow = res.data;
      this.printRow.createBy = row.createBy;
      this.printRow.createDept = row.createDept;
      this.printRow.createTime = row.createTime;
    },
  },
  filters: {
    formatStatus(val) {
      switch (val) {
        case "0":
          return "未提交";
        case "1":
          return "申请中";
        case "2":
          return "审批通过";
        case "3":
          return "审批拒绝";
        case "4":
          return "已抽取";
        case "5":
          return "已发布";
        case "6":
          return "待确认";
        case "7":
          return "项目执行中";
        case "8":
          return "项目完成";
      }
    },
  },
};
</script>
<style lang="scss" scoped>
textarea {
  outline: none;
}
.appraise-container {
  padding: 0 20px;
  .form-header {
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    border-bottom: unset;
    padding-top: 20px;
    .el-form-item {
      .search-btn {
        background-color: #1890ff;
      }
      .el-form-item__content {
        margin-left: 0 !important;
      }
    }
    .btns {
      margin-left: -50px;
    }
  }
  .pagination {
    display: flex;
    justify-content: flex-end;
    padding-top: 15px;
  }
}
::v-deep .el-table .cell {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
::v-deep .el-table .cell:hover {
  white-space: normal;
}
.score-wrap {
  padding: 15px;
  display: flex;
  flex-direction: column;
  label {
    width: 100px;
    text-align: right;
    padding-right: 8px;
  }
  .time-wrap {
    display: flex;
    width: 88%;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-left: -22px;
    .begin-time,
    .end-time {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      ::v-deep .el-input__inner {
        padding: 10px;
      }
      label {
        width: 103px;
      }
    }
    .begin-time {
      margin-left: 20px;
    }
  }
  .select-file {
    display: flex;
    padding-bottom: 20px;
    > label {
      width: 100px;
    }
    > .remain {
      width: calc(100% - 100px);
    }
  }
  .deduction-wrap {
    display: flex;
    align-items: baseline;
    margin-left: 0;
    > ul {
      padding: 0;
      li {
        list-style: none;
        display: flex;
        padding: 5px 0;
        > .deduction-title {
          width: 50%;
        }
      }
    }
  }
  .deduction-reason-wrap {
    display: flex;
    > textarea {
      width: 80%;
    }
  }
}
::v-deep .el-dialog__title {
  font-weight: 600;
}
::v-deep .el-dialog__body {
  padding: 0px 20px 30px 40px;
}
::v-deep .el-icon-date:before {
  content: "";
}
::v-deep .el-upload {
  text-align: left;
}
::v-deep .el-upload-list {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  .el-upload-list__item {
    width: 50%;
  }
}
// .tableComponent {
//   box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.08);
// }
.uploadimg-wrap {
  padding-top: 10px;
  > .uploadimg {
    margin-right: 10px;
    margin-bottom: 8px;
  }
}
.must {
  color: red;
  margin-right: 5px;
}
.current-score {
  color: #da0620;
  font-size: 18px;
  font-weight: 600;
  margin-top: 20px;
  margin-left: -55px;
}
.bigfont {
  font-size: 19px;
  font-weight: 100;
  text-align: center;
  font-family: FangSong;
}
.small {
  text-align: center;
  font-weight: 100;
  font-size: 16px;
}
.fontitem1 {
  vertical-align: top;
  font-size: 16px;
  font-weight: 100;
}
.fontitem12 {
  font-size: 16px;
}
.topfont {
  font-size: 16px;
  font-weight: 400;
}
.input {
  font-size: 18px;
  font-weight: 400;
}
.small1 {
  text-align: center;
  font-weight: 100;
  font-size: 20px;
}
.zhong {
  font-size: 16px;
  padding-left: 10px;
}
.form-img-out {
  width: 130px;
  height: 130px;
}
.form-img-line {
  width: 500px;
  height: 500px;
}
.form-dialog {
  text-align: center;
}
.topfont {
  font-size: 16px;
  font-weight: 400;
}
.project-name {
  font-family: FangSong;
}
.project-name-1 {
  font-family: FangSong;
}
.topfont-name {
  font-family: FangSong;
}
.font-family {
  font-family: FangSong;
}
.printTable {
  border: unset;
}
.noBorder {
  border: unset;
}
.rightBorder {
  border-right: 1px solid #9a9a9a;
}
.bottomBorder {
  border-bottom: 1px solid #9a9a9a;
}
.title {
  margin-bottom: 30px;
  font-size: 24px;
  font-family: SimSun;
}
.calc-cash {
  width: 220px;
  input {
    width: 100%;
  }
}
.cash-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-left: -19px;
  .right-opt {
    position: relative;
    right: 13px;
    align-self: center;
    text-align: center;
  }
}

.radio-wrap {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  margin-left: -50px;
  .label {
    display: inline-block;
    width: 162px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
    color: #666;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-right: 10px;
  }
}
</style>
